//
//  LoginManager.m
//  Haliaeetus
//
//  Created by junli hou on 2018/4/3.
//  Copyright © 2018年 BMY. All rights reserved.
//

#import "LoginManager.h"


@implementation LoginManager

+ (NSDictionary*) getUserLoginData
{
    NSUserDefaults* userfaults = [NSUserDefaults standardUserDefaults];
    return [userfaults objectForKey:@"user"];
}
+ (BOOL) getUserLoginStatus
{
    NSDictionary *userDic=[self getUserLoginData];
    NSString *token=[userDic objectForKey:@"private_token"];
    
    if ([token isEqualToString:@""]||token==NULL) {
           return NO;
    }else{
           return YES;
        
    }
}
+ (void) setUserData:(NSDictionary*)userDic
{
    NSUserDefaults* userfaults = [NSUserDefaults standardUserDefaults];
     [userfaults setObject:userDic forKey:@"user"];
}
+ (void) logOut
{
    NSUserDefaults* userfaults = [NSUserDefaults standardUserDefaults];
    [userfaults removeObjectForKey:@"user"];
}


+(NSString *)timeFormatted:(int)totalSeconds
{
    
    NSTimeInterval interval    =totalSeconds;
    NSDate *date               = [NSDate dateWithTimeIntervalSince1970:interval];
    
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
    NSString *dateString       = [formatter stringFromDate: date];
    
    return dateString;
}
@end
